home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / Jim's CDEFs v1.30 / demo Source ƒ / utilities / panelAssist.c < prev    next >
Encoding:
Text File  |  1994-11-05  |  2.4 KB  |  85 lines  |  [TEXT/KAHL]

  1. //----------------------------------------------------------------------------------
  2. //    File        : panelAssist.c
  3. //    Date        : August 24, 1994
  4. //    Author        : Jim Stout
  5. //    Purpose        : Some utility routines for use with the tabPanel CDEF.
  6. //
  7. //----------------------------------------------------------------------------------
  8. #include "dialogAssist.h"
  9. #include "panelAssist.h"
  10.  
  11. //----------------------------------------------------------------------------------
  12. //    Function: panelSwap
  13. //     Purpose: change a dialog panel in a dialog that uses the tabPanel CDEF.
  14. //
  15. //    NOTE: This routine assumes that the CountDITL, AppendDITL & ShortenDITL are
  16. //            available. (System 7 or CommToolbox is installed);
  17. //
  18. //   returns: void
  19. //----------------------------------------------------------------------------------
  20.  
  21. extern void panelSwap(DialogPtr theDialog, short firstPANEL, 
  22.                         short fromPanel, short toPanel, short ctlToKeep)
  23. {    
  24.     Handle            h;
  25.     short            toRemove=0;
  26.  
  27.     toRemove = CountDITL(theDialog) - ctlToKeep;
  28.         
  29.     h = GetResource('DITL', firstPANEL+toPanel);
  30.     if(h) {
  31.         if(toRemove)
  32.             ShortenDITL(theDialog, toRemove);
  33.         AppendDITL(theDialog, h, overlayDITL);
  34.         ReleaseResource(h);
  35.     }
  36.     else {
  37.         ShortenDITL(theDialog, toRemove);
  38.         toRemove = 0;
  39.     }
  40.     
  41. }
  42.  
  43. //----------------------------------------------------------------------------------
  44. //    Function: panelCmdKey
  45. //     Purpose: allow a cmd-key to operate the tabPanel CDEF.
  46. //
  47. //   returns: void
  48. //----------------------------------------------------------------------------------
  49.  
  50. extern Boolean panelCmdKey(DialogPtr theDialog, short panelID, char c, short *theItem)
  51. {
  52.     short    num;
  53.     
  54.      num = daGetCtlMax(theDialog, panelID) + 0x30;
  55.      if(c >= 0x31 && c <= num) {
  56.          num = c - 0x30;
  57.          daSetCtlValue(theDialog, panelID, num);
  58.          *theItem = panelID;
  59.          return(TRUE);
  60.      }
  61.      return(FALSE);
  62. }
  63. //----------------------------------------------------------------------------------
  64. //    Function: panelCmdTab
  65. //     Purpose: allow a cmd-tab to cycle thru tabs on the tabPanel CDEF.
  66. //
  67. //   returns: void
  68. //----------------------------------------------------------------------------------
  69.  
  70. extern Boolean panelCmdTab(DialogPtr theDialog, short panelID, char c, short *theItem)
  71. {
  72.     short    max,val;
  73.     
  74.      max = daGetCtlMax(theDialog, panelID);
  75.      val = daGetCtlValue(theDialog, panelID);
  76.      if(c == _TAB) {
  77.          val++;
  78.          if(val > max)
  79.              val = 1;
  80.          daSetCtlValue(theDialog, panelID, val);
  81.          *theItem = panelID;
  82.          return(TRUE);
  83.      }
  84.      return(FALSE);
  85. }